import type { CodeType, Patient, PatientList, User, UserInfo } from '@/types/user'
import { request } from '@/utils/request'
export const loginByPassword = (mobile: string, password: string) => {
  return request<User>('/login/password', 'POST', {
    mobile,
    password,
  })
}
export const sendMobileCode = (mobile: string, type: CodeType) => {
  return request('/code', 'GET', {
    mobile,
    type,
  })
}
// 短信登录
export const loginByCode = (mobile: string, code: string) => {
  return request<User>('/login', 'POST', {
    mobile,
    code,
  })
}
export const getUserInfo = () => {
  return request<UserInfo>('/patient/myUser', 'GET')
}
export const getPatientList = () => {
  return request<PatientList>('/patient/mylist', 'GET')
}
export const addPatient = (patient: Patient) => {
  return request('/patient/add', 'POST', patient)
}
export const updatePatient = (patient: Patient) => {
  return request('/patient/update', 'PUT', patient)
}
export const delPatient = (id: string) => {
  return request(`/patient/del/${id}`, 'DELETE')
}
// 获取患者详情
export const getPatientDetail = (id: string) => {
  return request<Patient>(`/patient/info/${id}`, 'GET')
}
// 获取未读数量
export const getUnreadCount = () => {
  return request<number>('/patient/message/unRead/all', 'GET')
}
export const loginByQQ = (openid: string) => {
  return request<User>('/login/thirdparty', 'POST', { openid, source: 'qq' })
}
export const bindMobile = (data: { mobile: string; code: string; openId: string }) => {
  return request<User>('/login/binding', 'POST', data)
}
